<template>
    <div :class="className">
        <TitleTips :title="title" />
        <BaseTable v-loading="listLoading" :columns="columns" :data="list" style="margin-bottom: 24px;"></BaseTable>
        <Pagination
            slot="pagination"
            style="text-align: right;"
            :current-page.sync="page.pageNo"
            :page-size.sync="page.pageSize"
            :total="page.total"
            @size-change="getList"
            @current-change="getList"
        />
    </div>
</template>

<script>
import { ContractModel } from '@/models'

export default {
    name: 'OperationLog',
    props: {
        className: {
            type: String,
            default: 'body'
        },
        title: {
            type: String,
            default: '合同操作日志'
        },
        type: {
            type: Number,
            default: 1 // 1合同 2、养护工程 3、养护记录
        }
    },
    data() {
        return {
            model: new ContractModel(),
            page: {
                pageNo: 1,
                pageSize: 10,
                total: 0
            },
            listLoading: false,
            list: [],
            columns: Object.freeze([
                {
                    attrs: {
                        prop: 'typeName',
                        label: '操作类型',
                        width: '160',
                        'show-overflow-tooltip': true
                    }
                },
                {
                    attrs: {
                        prop: 'operatorName',
                        label: '操作人',
                        width: '150',
                        'show-overflow-tooltip': true
                    }
                },
                {
                    attrs: {
                        prop: 'operatorOrgName',
                        label: '所属部门',
                        'min-width': '140',
                        'show-overflow-tooltip': true
                    }
                },
                {
                    attrs: {
                        prop: 'createTime',
                        label: '操作时间',
                        width: '170',
                    }
                }
            ])
        }
    },
    created () {
        this.getList()
    },
    methods: {
        getList() {
            this.listLoading = true
            // msType1合同 2、养护工程 3、养护记录
            this.model.logsList({dataId: this.$route.query.id, msType: this.type, ...this.page}).then(res => {
                this.list = res.list || []
                this.page.total = res.totalCount
            }).finally(() => {
                this.listLoading = false
            })
        }
    },
}
</script>

<style lang="scss" scoped>

</style>
